package org.bluedream.core.module.dao.bill.stkIn;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bluedream.core.module.entity.bill.stkIn.StkIn;
import org.bluedream.core.module.entity.bill.stkIn.StkInBack;

import java.io.Serializable;

/**
 * @ClassName StkInBackDao
 * @Description TODO
 * @Author foxsand
 * @Data 14:53
 * @Version
 */
public interface StkInBackDao extends BaseMapper<StkInBack> {
    @Override
    @Select("select stkInBack.bill_type as billType , stkInBack.bill_num as billNum , stkInBack.check_date as checkDate , stkInBack.check_by as checkBy , " +
            "stkInBack.war_code as warCode , c.name as warName , " +
            "stkInBack.supplier_code as supplierCode , b.name as supplierName , stkInBack.qty as qty , stkInBack.total as total , " +
            " stkInBack.id as id , stkInBack.create_by as createBy , stkInBack.create_date as createDate , stkInBack.update_by as updateBy , stkInBack.update_date as updateDate , stkInBack.status as status , stkInBack.remarks as remarks" +
            " from StkInBack StkInBack, tSupplier b , warehouse c " +
            "${ew.customSqlSegment} and stkInBack.supplier_code = b.code and stkInBack.war_code = c.code")
    IPage<StkInBack> selectPage(IPage<StkInBack> page, @Param("ew") Wrapper<StkInBack> queryWrapper);

    @Override
    @Select("select stkInBack.bill_type as billType , stkInBack.bill_num as billNum , stkInBack.check_date as checkDate , check_by as checkBy , " +
            "stkInBack.war_code as warCode , wareHouse.name as warName , " +
            "stkInBack.supplier_code as supplierCode , supplier.name as supplierName , stkInBack.qty as qty , stkInBack.total as total , " +
            " stkInBack.id as id , stkInBack.create_by as createBy , stkInBack.create_date as createDate , stkInBack.update_by as updateBy , stkInBack.update_date as updateDate , stkInBack.status as status , stkInBack.remarks as remarks , " +
            " supplier.id as \"supplier.id\" , supplier.code as \"supplier.code\" , supplier.name as \"supplier.name\" , " +
            " wareHouse.id as \"wareHouse.id\" , wareHouse.code as \"wareHouse.code\" , wareHouse.name as \"wareHouse.name\"" +
            " from stkInBack stkInBack, tSupplier supplier , warehouse wareHouse " +
            "where stkInBack.id = #{id} and stkInBack.supplier_code = supplier.code and stkInBack.war_code = wareHouse.code")
    StkInBack selectById(Serializable id);
}
